package com.wj.controller.html;

import com.jfinal.weixin.sdk.kit.PaymentKit;
import com.wj.domain.Girl;
import com.wj.repository.GirlRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wj on 2017/9/11.
 */

@Controller
public class JumpController {

    @RequestMapping("/jumpweibo.html")
    public String getCodeView(ModelAndView modelAndView){
        return "jump/weibo_jump";
    }


    @RequestMapping("/weibo.html")
    public ModelAndView weibo(ModelAndView modelAndView){
        Map<String, String> params = new HashMap<String, String>();
        params.put("appid", "3047603970");
        params.put("client_secret", "96b4fe2f8638aa4200b23a096db4aaef");
        params.put("redirect_uri", "http://saqw.cn/jumpweibo.html");
        String para = PaymentKit.packageSign(params, false);
        modelAndView.setViewName("redirect:/jumpweibo.html?"+para);
        return modelAndView;
    }

    /**
     * qq登录中转页面
     * @param modelAndView
     * @return
     */
    @RequestMapping("/jumpqq.html")
    public String jumpqq(ModelAndView modelAndView){
        return "jump/qq_jump";
    }


    /**
     * qq登录参数拼装
     * @param modelAndView
     * @return
     */
    @RequestMapping("/qq.html")
    public ModelAndView qq(ModelAndView modelAndView){
//        https://graph.qq.com/oauth2.0/show?which=Login&display=pc&client_id=101411687&redirect_uri=http://dtfind.com/afterQQLogin.html&response_type=code&state=d90abe912cceef12f60454bed6e1edc2&scope=get_user_info
        Map<String, String> params = new HashMap<String, String>();
        params.put("client_id", "101442533");
        params.put("state", "d90abe912cceef12f60454bed6e1edc2");
//        params.put("client_secret", "f790aac7f57c16720d4067c617d2882e");
        params.put("redirect_uri", "http://myqpp.tunnel.qydev.com/jumpqq.html");
        String para = PaymentKit.packageSign(params, false);
        modelAndView.setViewName("redirect:/jumpqq.html?"+para);
        return modelAndView;
    }


    /**
     * qq页面返回
     * @param modelAndView
     * @return
     */
    @RequestMapping("/qqhtml.html")
    public String qqhtml(ModelAndView modelAndView){
        return "jump/qqhtml";
    }


    /**
     * 微博页面返回
     * @param modelAndView
     * @return
     */
    @RequestMapping("/wbhtml.html")
    public String wbhtml(ModelAndView modelAndView){
        return "jump/wbhtml";
    }

    /**
     * 微博页面返回
     * @param modelAndView
     * @return
     */
    @RequestMapping("/")
    public String wb(ModelAndView modelAndView){
        return "jump/wbhtml";
    }


    /**
     * qq登录参数拼装
     * @param modelAndView
     * @return
     */
    @RequestMapping("/weibologin.html")
    public ModelAndView weibo1(ModelAndView modelAndView){

        modelAndView.setViewName("jump/weibojs");
        return modelAndView;
    }
}
